package org.openharmony.qttool.qml.language;

import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.patterns.PlatformPatterns;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;

public class QmlCompletionContributor extends CompletionContributor {
    public QmlCompletionContributor() {
        extend(CompletionType.BASIC,
                PlatformPatterns.psiElement().withLanguage(QmlLanguage.INSTANCE),
                new CompletionProvider<CompletionParameters>() {
                    @Override
                    protected void addCompletions(@NotNull CompletionParameters completionParameters, @NotNull ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
                        completionResultSet.addElement(LookupElementBuilder.create("import"));
                        completionResultSet.addElement(LookupElementBuilder.create("property"));
                        completionResultSet.addElement(LookupElementBuilder.create("signal"));
                        completionResultSet.addElement(LookupElementBuilder.create("function"));
                        completionResultSet.addElement(LookupElementBuilder.create("string"));
                        completionResultSet.addElement(LookupElementBuilder.create("alias"));
                        completionResultSet.addElement(LookupElementBuilder.create("variant"));
                        completionResultSet.addElement(LookupElementBuilder.create("if"));
                        completionResultSet.addElement(LookupElementBuilder.create("do"));
                        completionResultSet.addElement(LookupElementBuilder.create("while"));

                        completionResultSet.addElement(LookupElementBuilder.create("Item"));
                        completionResultSet.addElement(LookupElementBuilder.create("Rectangle"));
                        completionResultSet.addElement(LookupElementBuilder.create("Text"));
                        completionResultSet.addElement(LookupElementBuilder.create("Image"));
                        completionResultSet.addElement(LookupElementBuilder.create("MouseArea"));
                        completionResultSet.addElement(LookupElementBuilder.create("Column"));
                        completionResultSet.addElement(LookupElementBuilder.create("Row"));
                        completionResultSet.addElement(LookupElementBuilder.create("Grid"));
                        completionResultSet.addElement(LookupElementBuilder.create("ListView"));
                        completionResultSet.addElement(LookupElementBuilder.create("Loader"));
                        completionResultSet.addElement(LookupElementBuilder.create("Button"));
                        completionResultSet.addElement(LookupElementBuilder.create("Slider"));

                        completionResultSet.addElement(LookupElementBuilder.create("id"));
                        completionResultSet.addElement(LookupElementBuilder.create("width"));
                        completionResultSet.addElement(LookupElementBuilder.create("height"));
                        completionResultSet.addElement(LookupElementBuilder.create("color"));
                        completionResultSet.addElement(LookupElementBuilder.create("anchors"));
                        completionResultSet.addElement(LookupElementBuilder.create("x"));
                        completionResultSet.addElement(LookupElementBuilder.create("y"));
                        completionResultSet.addElement(LookupElementBuilder.create("visible"));
                        completionResultSet.addElement(LookupElementBuilder.create("enabled"));
                        completionResultSet.addElement(LookupElementBuilder.create("opacity"));
                        completionResultSet.addElement(LookupElementBuilder.create("rotation"));
                        completionResultSet.addElement(LookupElementBuilder.create("scale"));
                        completionResultSet.addElement(LookupElementBuilder.create("z"));

                        completionResultSet.addElement(LookupElementBuilder.create("onClicked"));
                        completionResultSet.addElement(LookupElementBuilder.create("onPressed"));
                        completionResultSet.addElement(LookupElementBuilder.create("onReleased"));
                        completionResultSet.addElement(LookupElementBuilder.create("onCompleted"));
                        completionResultSet.addElement(LookupElementBuilder.create("onVisibleChanged"));
                        completionResultSet.addElement(LookupElementBuilder.create("onWidthChanged"));
                        completionResultSet.addElement(LookupElementBuilder.create("onHeightChanged"));
                        completionResultSet.addElement(LookupElementBuilder.create("onXChanged"));
                        completionResultSet.addElement(LookupElementBuilder.create("onYChanged"));
                        completionResultSet.addElement(LookupElementBuilder.create("onOpacityChanged"));
                    }
                }
        );
    }
}
